<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<body style="overflow:hidden;">
<div id="pruduce_order_list_grid-div">
    <!-- 隐藏区域：存放查询条件 -->
    <form id="pruduce_order_list_hiddenQueryForm" action="<%=path%>/produceOrder/toExcel" method="POST" style="display:none;" >
        <input id="pruduce_order_list_ids" name="ids" value=""/>
        <!-- 生产订单号 -->
        <input name="orderCode" id="pruduce_order_list_orderCode" />
        <!-- 计划日期 -->
        <input name="orderPlanTime1" id="pruduce_order_list_orderPlanTime1" />
    </form>
    <div class="query_box" id="pruduce_order_list_yy" title="查询选项">
            <form id="pruduce_order_list_queryForm" style="max-width:100%;">
			 <ul class="form-elements">
				<li class="field-group field-fluid2">
					<label class="inline" for="pruduce_order_list_orderCode" style="margin-right:20px;width:100%;">
						<span class="form_label" style="width:78px;">生产订单号：</span>
						<input type="text" id="pruduce_order_list_orderCode" name="orderCode" value="" style="width: calc(100% - 83px);" placeholder="生产订单号">
					</label>
				</li>
				<li class="field-group field-fluid2">
					<label class="inline" for="pruduce_order_list_orderPlanTime1" style="margin-right:20px;width:100%;">
						<span class="form_label" style="width:65px;">计划日期：</span>
						<input type="text" class="form-control date-picker" id="pruduce_order_list_orderPlanTime1" name="orderPlanTime1" value="" style="width: calc(100% - 83px);" placeholder="计划日期">
					</label>
				</li>
			</ul>
			<div class="field-button" style="">
				<div class="btn btn-info" onclick="queryOk();">
		            <i class="ace-icon fa fa-check bigger-110"></i>查询
	            </div>
				<div class="btn" onclick="reset();"><i class="ace-icon icon-remove"></i>重置</div>
	        </div>
		  </form>
    </div>
    <div id="pruduce_order_list_fixed_tool_div" class="fixed_tool_div">
        <div id="pruduce_order_list___toolbar__" style="float:left;overflow:hidden;"></div>
    </div>
    <!--    物料信息表格 -->
    <table id="pruduce_order_list_grid-table" style="width:100%;height:100%;"></table>
    <!-- 	表格分页栏 -->
    <div id="pruduce_order_list_grid-pager"></div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/static/js/techbloom/wms/ordermanage/produceorder/produceorder.js"></script>
<script type="text/javascript">
    var context_path = '<%=path%>';
    var oriData;      //表格数据
    var _grid;        //表格对象
    var dynamicDefalutValue="d3d15d50efc94289b114693b418f1e4c";
    $(function  (){
       $(".toggle_tools").click();
    });
    $(function()
    {
        //工具栏
$("#pruduce_order_list___toolbar__").iToolBar({
     id:"pruduce_order_list___tb__01",
     items:[
        {label:"添加",disabled:(${sessionUser.addQx}==1?false:true),onclick:add,iconClass:'icon-plus'},
        {label:"编辑",disabled:(${sessionUser.editQx}==1?false:true),onclick:edit,iconClass:'icon-pencil'},
        {label:"删除",disabled:(${sessionUser.deleteQx}==1?false:true),onclick:del,iconClass:'icon-trash'},
        {label:"审核",disabled:(${sessionUser.queryQx}==1?false:true),onclick:auditOrder,iconClass:'icon-ok-circle'},
        {label:"生成出库计划",disabled:(${sessionUser.queryQx}==1?false:true),onclick:spilt,iconClass:'icon-plus'},
        {label:"导出",disabled:(${sessionUser.queryQx}==1?false:true),onclick:exportExcel,iconClass:'icon-share'},
        {label:"打印", disabled:(${sessionUser.queryQx} == 1 ? false : true),onclick:print,iconClass:' icon-print'}
     ]
});
$(".date-picker").datetimepicker({format: "YYYY-MM-DD"});
        //初始化表格
        _grid = jQuery("#pruduce_order_list_grid-table").jqGrid({
            url : context_path + "/produceOrder/toList",
            datatype : "json",
            colNames : [ "主键","生产订单号","订单创建时间","订单计划日期","所属单据","状态"],
            colModel : [
                {name : "id",index : "id",width : 100,hidden:true},
                {name : "orderCode",index : "orderCode",width : 100},
                {name : "orderCreatTime1",index:"orderCreatTime1",width : 100,
                    formatter:function (cellvalue,option,rowObject) {
                        if(cellvalue){
                            return cellvalue.substring(0,19);
                        }else{
                            return "";
                        }
                    }},
                {name :"orderPlanTime1",index:"orderPlanTime1",width:100,
                    formatter:function (cellvalue,option,rowObject) {
                        if(cellvalue){
                            return cellvalue.substring(0,19);
                        }else{
                            return "";
                        }
                    }
                },
                {name : "saleNo",index:"saleNo",width:100},
                {name : "state",index:"state",width:50,formatter:function(cellvalue,option,rowObject){
                    if(cellvalue==0){
                        return "<span style='color:red;font-weight:bold;'>未审核</span>";
                    }
                    if(cellvalue==1){
                        return "<span style='color:green;font-weight:bold;'>已审核</span>";
                    }
                        if(cellvalue==2){
                            return "<span style='color:red;font-weight:bold;'>计划中</span>";
                        }
                        if(cellvalue==3){
                            return "<span style='color:green;font-weight:bold;'>已完成</span>";
                        }
                    }
                }
            ],
            rowNum : 20,
            rowList : [ 10, 20, 30,40,50,70,100 ],
            pager : "#pruduce_order_list_grid-pager",
            sortname : "po.id",
            sortorder : "desc",
            altRows: true,
            viewrecords : true,
            autowidth:true,
            multiselect:true,
            multiboxonly: true,
            beforeRequest:function (){
                dynamicGetColumns(dynamicDefalutValue,"pruduce_order_list_grid-table",$(window).width()-$("#sidebar").width() -7);
                //重新加载列属性
            },
            loadComplete : function(data)
            {
                var table = this;
                setTimeout(function(){updatePagerIcons(table);enableTooltips(table);}, 0);
                oriData = data;
                $(window).triggerHandler("resize.jqGrid");
            },
            emptyrecords: "没有相关记录",
            loadtext: "加载中...",
            pgtext : "页码 {0} / {1}页",
            recordtext: "显示 {0} - {1}共{2}条数据"
        });
        //在分页工具栏中添加按钮
        jQuery("#pruduce_order_list_grid-table").navGrid("#pruduce_order_list_grid-pager",{edit:false,add:false,del:false,search:false,refresh:false}).navButtonAdd("#pruduce_order_list_grid-pager",{
                caption:"",
                buttonicon:"ace-icon fa fa-refresh green",
                onClickButton: function(){
                    $("#pruduce_order_list_grid-table").jqGrid("setGridParam",
                        {
                            postData: {queryJsonString:""} //发送数据
                        }
                    ).trigger("reloadGrid");
                }
            }).navButtonAdd("#pruduce_order_list_grid-pager",{
                caption: "",
                buttonicon:"fa  icon-cogs",
                onClickButton : function (){
                    jQuery("#pruduce_order_list_grid-table").jqGrid("columnChooser",{
                        done: function(perm, cols){
                            dynamicColumns(cols,dynamicDefalutValue);
                            $("#pruduce_order_list_grid-table").jqGrid( "setGridWidth", $("#pruduce_order_list_grid-div").width()-3);
                        }
                    });
                }
            });

        $(window).on("resize.jqGrid", function () {
            $("#pruduce_order_list_grid-table").jqGrid("setGridWidth", $("#pruduce_order_list_grid-div").width() - 3 );
            var height = $("#header").outerHeight(true)+
                $("#pruduce_order_list_yy").outerHeight(true)+
                $("#pruduce_order_list_grid-pager").outerHeight(true)+
                $("#pruduce_order_list_fixed_tool_div").outerHeight(true)+
                $("#breadcrumb").outerHeight(true)+
                $("#gview_pruduce_order_list_grid-table .ui-jqgrid-hbox").outerHeight(true);
                $("#pruduce_order_list_grid-table").jqGrid("setGridHeight", (document.documentElement.clientHeight) - height);
        });


    });
    var _queryForm_data = iTsai.form.serialize($("#pruduce_order_list_queryForm"));
    function queryOk(){
        var queryParam = iTsai.form.serialize($("#pruduce_order_list_queryForm"));
        //执行父窗口中的js方法：将当前窗口中的form的值传递到父窗口，并放到父窗口中隐藏的form中，接着执行刷新父窗口列表的操作
        queryInstoreListByParam(queryParam);

    }
    function reset(){
        iTsai.form.deserialize($('#pruduce_order_list_queryForm'),_queryForm_data);
        //执行父窗口中的js方法：将当前窗口中的form的值传递到父窗口，并放到父窗口中隐藏的form中，接着执行刷新父窗口列表的操作
        queryInstoreListByParam(_queryForm_data);
    }

</script>
